/*
 * ListViewEx
 * Copyright (C) 2008, Philip Pronin (philip.pronin@gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LISTVIEWEX_H
#define LISTVIEWEX_H

#include <QWidget>
#include "ui_listViewEx.h"

QT_FORWARD_DECLARE_CLASS(QStandardItemModel)
QT_FORWARD_DECLARE_CLASS(QStandardItem)
QT_FORWARD_DECLARE_CLASS(QItemSelectionModel)

class ListViewEx: public QWidget, private Ui_ListViewEx {
	Q_OBJECT
	Q_PROPERTY(QStandardItemModel* model READ getModel)

public:
	ListViewEx(QWidget* parent = NULL);
	virtual ~ListViewEx() {}

	QStandardItemModel* getModel() const;
	QItemSelectionModel* getSelectionModel() const;

signals:
	void beforeUpdate();
	void addClicked();
	void beforeRowDelete(const QList<QStandardItem*>& list);
	void selectionChanged(const QItemSelection& selected);

private slots:
	void deleteItem();
	void upItem();
	void downItem();

	void selectionChangedSlot(const QItemSelection& selected);

private:
	QStandardItemModel* model;
	void moveItems(int pos);
	bool canMoveItems(int pos) const;
};

#endif /* LISTVIEWEX_H */
